import { useContext } from 'react';
import { AdaptiveSheetContext } from '../contexts/external';
import type { AdaptiveSheetMethods, AdaptiveSheetVariables } from '../types';

export const useAdaptiveSheet = (): AdaptiveSheetMethods & AdaptiveSheetVariables => {
  const context = useContext(AdaptiveSheetContext);

  if (context === null) {
    throw "'useAdaptiveSheet' cannot be used out of the AdaptiveSheet!";
  }

  return context;
};
